import { PoemTag } from 'src/modules/poem-tags/entities/poem-tag.entity';
import { Poet } from 'src/modules/poet/entities/poet.entity';
import {
  Column,
  Entity,
  JoinTable,
  ManyToMany,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';

@Entity()
export class Poem {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column({ type: 'text' })
  content: string;

  @Column({ nullable: true, type: 'text' })
  translate: string; //译文

  @Column({ nullable: true, type: 'text' })
  notes: string; //注释

  @ManyToOne(() => Poet, (poet) => poet.poems)
  poet: Poet;

  @ManyToMany(() => PoemTag, (poemTag) => poemTag.poems)
  @JoinTable()
  poemTags: PoemTag[];
}
